﻿@model LbangCMS.Areas.Admin.Models.CompanyInfoModel
@{
    ViewBag.Title = "EditCompanyInfo";
    Layout = "~/Areas/Admin/Views/Shared/_FormLayout.cshtml";
}
@section head{
    <link href="~/Areas/Admin/content/libs/zui/css/zui.css" rel="stylesheet" />
<link href="~/Areas/Admin/content/libs/zui/css/zui-theme.css" rel="stylesheet" />
<link href="~/Areas/Admin/Content/libs/layer/skin/layer.css" rel="stylesheet" />
<link href="~/Areas/Admin/Content/libs/layer/skin/layer.ext.css" rel="stylesheet" />
<link href="~/Areas/Admin/Content/libs/zui/lib/datatable/zui.datatable.css" rel="stylesheet" />
<style type="text/css">
    body {
        padding: 10px 20px;
    }

    div.panel form {
        margin: 5px 5px;
    }

    .form-control.error {
        border: 1px dotted #cc5965;
    }

    label.error {
        color: #cc5965;
        display: inline-block;
        margin-left: 5px;
        margin-bottom: 0px;
    }

    .layui-layer-content ul.state-error li {
        color: red;
    }

    div.panel {
        border: none;
    }
</style>

    }


<div class="panel">
    <div style="margin:100px auto;width:800px;">
        @using (Html.BeginForm("EditCompanyInfo", "Home", FormMethod.Post, new { @id = "form", @class = "form-horizontal" }))
        {
            <div class="form-group">
                <label class="col-md-4 control-label required">公司名称</label>
                <div class="col-md-6">
                    @Html.TextBoxFor(model => model.CompanyName, new { @class = "form-control" })
                </div>
            </div>


            <div class="form-group">
                <label class="col-md-4 control-label required">地址</label>
                <div class="col-md-6">
                    @Html.TextBoxFor(model => model.Address, new { @class = "form-control" })
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-4 control-label required">电话</label>
                <div class="col-md-6">
                    @Html.TextBoxFor(model => model.Phone, new { @class = "form-control" })
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-4 control-label required">传真</label>
                <div class="col-md-6">
                    @Html.TextBoxFor(model => model.Fax, new { @class = "form-control" })
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-4 control-label required">邮编</label>
                <div class="col-md-6">
                    @Html.TextBoxFor(model => model.Zipcode, new { @class = "form-control" })
                </div>
            </div>

            <div class="form-group">
                <div class="col-md-offset-4 col-md-4">
                    <input type="button" id="submit" class="btn btn-primary" onclick="submitForm()" value="保存">
                </div>
            </div>
        }
    </div>
</div>
@section script {
<script src="~/Areas/Admin/content/libs/jquery/jquery-1.10.2.min.js"></script>
<script src="~/Areas/Admin/content/libs/jquery/jquery.form.js"></script>
<script src="~/Areas/Admin/content/libs/zui/js/zui.min.js"></script>
<script src="~/Areas/Admin/content/libs/com.js"></script>

<script src="~/Areas/Admin/content/libs/validate/jquery.validate.min.js"></script>
<script src="~/Areas/Admin/content/libs/validate/additional-methods.min.js"></script>
<script src="~/Areas/Admin/content/libs/validate/custom-additional-methods.js"></script>
<script src="~/Areas/Admin/content/libs/validate/messages_zh.min.js"></script>

<script src="~/Areas/Admin/Content/libs/layer/layer.js"></script>
<script src="~/Areas/Admin/Content/libs/layer/extend/layer.ext.js"></script>
    <script type="text/javascript">
        $().ready(function () {
            $("#form").validate({
                rules: {
                    CompanyName: {
                        required: true,
                    },
                    Address: {
                        required: true,
                    },
                    Phone: {
                        required: true,
                    },
                    Fax: {
                        required: true,
                    },
                    Zipcode: {
                        required: true,
                    }
                },
                messages: {
                    CompanyName: {
                        required: "请输入公司名",
                    },
                    Address: {
                        required: "请输入公司地址",
                    },
                    Phone: {
                        required: "请输入公司电话",
                    },
                    Fax: {
                        required: "请输入传真号码",
                    },
                    Zipcode: {
                        required: "请输入邮编",
                    }
                },
                onfocusout: function(element) { $(element).valid(); },
                errorPlacement: function (error, element) {
                    if (element.is(":radio")) {
                        error.appendTo(element.parent());
                    }
                    if (element.is(":checkbox"))
                        error.appendTo(element.parent());
                    else
                        error.appendTo(element.parent());
                }

            });
        })

        function submitForm(msg) {
            com.submitForm({
                isValid: true,
                $form: $("#form"),
                success: function (result) {
                    if (result.success) {
                        layer.msg("保存成功");
                    } else {
                        layer.alert(result.msg);
                    }
                }
            });
        }
    </script>
}


